import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Vector;

public class ClassNameIndex {
	static Vector<ClassName> classNames;

	private static void init() {
		Scanner input;
		classNames = new Vector<ClassName>();
		try {
			input = new Scanner(new File(DirectoryUtil.TYPE_AND_CU_PATH));
			while (input.hasNext()) {
				String stmt = input.nextLine();
				String[] stmts = stmt.split(" ");
				classNames.add(new ClassName(stmts[0], Integer
						.parseInt(stmts[1])));
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static Vector<String> getClassName(int index) {
		if (classNames == null) {
			init();
		}
		Vector<String> result = new Vector<String>();
		for (int i = 0; i < classNames.size(); i++) {
			if (classNames.get(i).classIndex == index) {
				result.add(classNames.get(i).className);
			}
		}
		return result;
	}

	public static int getClassNum(String className) {
		if (classNames == null) {
			init();
		}
		for (int i = 0; i < classNames.size(); i++) {
			if (classNames.get(i).className.equals(className)) {
				return classNames.get(i).classIndex;
			}
		}
		return -1;
	}
}

class ClassName {
	public String className;
	public int classIndex;

	public ClassName(String className, int classIndex) {
		this.className = className;
		this.classIndex = classIndex;
	}
}
